<html>
<head><meta charset="utf-8"><title>Semantic hash for Cargo project · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Semantic.20hash.20for.20Cargo.20project.html">Semantic hash for Cargo project</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210683861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Semantic%20hash%20for%20Cargo%20project/near/210683861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Adelbert <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Semantic.20hash.20for.20Cargo.20project.html#210683861">(Sep 20 2020 at 20:30)</a>:</h4>
<p>Hey folks, I was hoping I'd be able to get a semantic hash of a Cargo project, at least one that encompasses the Rust dependencies. Originally I thought hashing the contents of <code>Cargo.lock</code> would be sufficient, but it looks like if we use path dependencies, changing the contents of said path dependency would not influence the hash of the <code>Cargo.lock</code> - is there an easy way I can get some hash of a Cargo Rust project that would identify the source tree of the project as well as all its dependencies?</p>



<a name="210689620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Semantic%20hash%20for%20Cargo%20project/near/210689620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Semantic.20hash.20for.20Cargo.20project.html#210689620">(Sep 20 2020 at 23:00)</a>:</h4>
<p><span class="user-mention" data-user-id="344504">@Adelbert</span> Cargo itself definitely has that information. You're effectively looking for a hash that changes whenever Cargo would choose to rebuild?</p>



<a name="210690134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Semantic%20hash%20for%20Cargo%20project/near/210690134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Adelbert <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Semantic.20hash.20for.20Cargo.20project.html#210690134">(Sep 20 2020 at 23:15)</a>:</h4>
<p>ah yes! i did not actually think about it that way but yeah, since Cargo can detect when there is a chance in the path dependency as well</p>



<a name="210690316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Semantic%20hash%20for%20Cargo%20project/near/210690316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Adelbert <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Semantic.20hash.20for.20Cargo.20project.html#210690316">(Sep 20 2020 at 23:21)</a>:</h4>
<p>i think the tricky bit here is if Cargo itself exposes a library. I found <code>cargo-toml</code> but that seems to just be about parsing</p>



<a name="210690396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Semantic%20hash%20for%20Cargo%20project/near/210690396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Adelbert <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Semantic.20hash.20for.20Cargo.20project.html#210690396">(Sep 20 2020 at 23:23)</a>:</h4>
<p>Though there is also the additional requirement that I want to compute a hash that would be unique to the state that Cargo is using to determine if it needs to rebuild</p>



<a name="210714519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Semantic%20hash%20for%20Cargo%20project/near/210714519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Semantic.20hash.20for.20Cargo.20project.html#210714519">(Sep 21 2020 at 08:47)</a>:</h4>
<p>Cargo uses timestamps to detect source file changes, not hashes. <a href="https://github.com/rust-lang/rust/issues/75594">rust-lang/rust#75594</a> and <a href="https://github.com/rust-lang/cargo/issues/8623">rust-lang/cargo#8623</a> will make it possible to use a hash for source files. For now you can look at the dep-info files (<code>.d</code>) and hash all mentioned files.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>